home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / KOOB / creator / editor / editor.cs < prev    next >
Text File  |  2006-09-24  |  4KB  |  151 lines

  1. //-----------------------------------------------------------------------------
  2. // Torque Game Engine 
  3. // Copyright (C) GarageGames.com, Inc.
  4. //-----------------------------------------------------------------------------
  5.  
  6.  
  7. //------------------------------------------------------------------------------
  8. // Hard coded images referenced from C++ code
  9. //------------------------------------------------------------------------------
  10.  
  11. //   editor/SelectHandle.png
  12. //   editor/DefaultHandle.png
  13. //   editor/LockedHandle.png
  14.  
  15.  
  16. //------------------------------------------------------------------------------
  17. // Functions
  18. //------------------------------------------------------------------------------
  19.  
  20. //------------------------------------------------------------------------------
  21. // Mission Editor 
  22. //------------------------------------------------------------------------------
  23.  
  24. function Editor::create()
  25. {
  26.    // Not much to do here, build it and they will come...
  27.    // Only one thing... the editor is a gui control which
  28.    // expect the Canvas to exist, so it must be constructed
  29.    // before the editor.
  30.    new EditManager(Editor)
  31.    {
  32.       profile = "GuiContentProfile";
  33.       horizSizing = "right";
  34.       vertSizing = "top";
  35.       position = "0 0";
  36.       extent = "640 480";
  37.       minExtent = "8 8";
  38.       visible = "1";
  39.       setFirstResponder = "0";
  40.       modal = "1";
  41.       helpTag = "0";
  42.       open = false;
  43.    };
  44. }
  45.  
  46.  
  47. function Editor::onAdd(%this)
  48. {
  49.    // Basic stuff
  50.    exec("./cursors.cs");
  51.  
  52.    // Tools
  53.    exec("./editor.bind.cs");
  54.    exec("./ObjectBuilderGui.gui");
  55.  
  56.    // New World Editor
  57.    exec("./EditorGui.gui");
  58.    exec("./EditorGui.cs");
  59.  
  60.    // World Editor
  61.    exec("./WorldEditorSettingsDlg.gui");
  62.  
  63.    // Terrain Editor
  64.    exec("./TerrainEditorVSettingsGui.gui");
  65.  
  66.    // Ignore Replicated fxStatic Instances.
  67.    EWorldEditor.ignoreObjClass("fxShapeReplicatedStatic");
  68.  
  69.    // do gui initialization...
  70.    EditorGui.init();
  71.  
  72.    //
  73.    exec("./editorRender.cs");
  74. }
  75.  
  76. function Editor::checkActiveLoadDone()
  77. {
  78.    if(isObject(EditorGui) && EditorGui.loadingMission)
  79.    {
  80.       Canvas.setContent(EditorGui);
  81.       EditorGui.loadingMission = false;
  82.       return true;
  83.    }
  84.    return false;
  85. }
  86.  
  87. //------------------------------------------------------------------------------
  88. function toggleEditor(%make)
  89. {
  90.    if (%make)
  91.    {
  92.       if (!$missionRunning) 
  93.       {
  94.          // just in case ...
  95.          disconnect();
  96.          Editor.close();
  97.          
  98.          // Allow users to override if they want.
  99.          %newMission = "~/data/newMission.mis";
  100.          if($Editor::newMissionOverride !$= "")
  101.             %newMission = $Editor::newMissionOverride;
  102.          
  103.          createServer( "SinglePlayer", expandFilename(%newMission));
  104.          %conn = new GameConnection(ServerConnection);
  105.          RootGroup.add(ServerConnection);
  106.          %conn.setConnectArgs($pref::Player::Name);
  107.          %conn.setJoinPassword($Client::Password);
  108.          %conn.connectLocal();
  109.          
  110.          Editor::create();
  111.          MissionCleanup.add(Editor);
  112.          EditorGui.loadingMission = true;
  113.          EditorGui.saveAs = true;
  114.          Editor.open();
  115.  
  116.          $dropcameracount = 0;
  117.          schedule(100,0,dropFreakinCameraAtPlayer);
  118.       }
  119.       else
  120.       {
  121.          if (!isObject(Editor))
  122.          {
  123.             Editor::create();
  124.             MissionCleanup.add(Editor);
  125.          }
  126.          
  127.          if (Canvas.getContent() == EditorGui.getId())
  128.             if (MissionInfo.type $= "DemoScene") 
  129.             {
  130.                commandToServer('dropPlayerAtCamera');
  131.                Editor.close("SceneGui");   
  132.             } 
  133.             else 
  134.             {
  135.                Editor.close("PlayerInterface"); ///***KCF***-24-SEP-2006 
  136.             }
  137.          else 
  138.          {
  139.             if (MissionInfo.type $= "DemoScene")
  140.                commandToServer('dropCameraAtPlayer');
  141.                
  142.             Editor.open();
  143.          }
  144.       }
  145.    }
  146. }
  147.  
  148. //------------------------------------------------------------------------------
  149. //  The editor action maps are defined in editor.bind.cs
  150. GlobalActionMap.bind(keyboard, "f11", toggleEditor);
  151.